package dao.impl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import dao.TypesDao;
import dao.pojo.Types;

public class TypesDaoImpl extends BaseDaoImpl implements TypesDao {

	public Types getTypes(Types type) {
		Connection conn=getPool().getConnection();
		
		ResultSet rs=null;
		PreparedStatement pstmt=null;
		Types types=null;
		String sql="SELECT * FROM types WHERE id=?";
		
		try {
			pstmt=conn.prepareStatement(sql);
			pstmt.setInt(1,type.getId());
			rs=pstmt.executeQuery();
			while(rs.next()){
				types=new Types();
				types.setId(rs.getInt("id"));
				types.setTypeName(rs.getString("type_name"));
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}finally{
			getPool().freeConnection(conn);
		}
		
		return types;
	}
	
}
